package org.lib.postgresqlhello.record;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import lombok.extern.slf4j.Slf4j;

/**
 * RecordController
 * @author ben
 * @date 2021-11-18 22:30:16 CST
 */
@RestController
@RequestMapping(value="/api/record")
@Slf4j
public class RecordController {

	@Autowired
	private RecordMapper rm;
	
	@GetMapping(value="/insert")
	public Integer insertlog(@RequestParam String data) {
		log.info("data.length=" + data.length());
		if (StringUtils.hasText(data)) {
			return rm.insertLog(data);
		} else {
			log.warn("data is blank.");
			return 0;
		}
	}
	
}
